Skip to content

Conversation

@pelekon
Copy link
Contributor

@pelekon pelekon commented Nov 22, 2025

Resolves: #352

public subscript() -> Int {
get { return len }
set { len = newValue }
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a case with parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice I lost them in git stash :/ Fixed


public subscript() -> Int {
get { return len }
set { len = newValue }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it set some other value and not the len perhaps? Just so we don't step on values when we write bigger tests

try (var arena = AllocatingSwiftArena.ofConfined()) {
MySwiftStruct s = MySwiftStruct.init(1337, 42, arena);
long currentValue = s.getSubscript();
s.setSubscript(66);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

import java.lang.invoke.*;
import java.util.*;
import java.nio.charset.StandardCharsets;
""",])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably skip the imports from these tests; the more these tests assert text the more annoying it is to change things in the future;

Let's just test the things that this specific "feature" is

super(segment, arena);
}
"""
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove those thunks too, let's not assert anything that's not related to the actual subscripts -- like these chunks

$ensureAlive();
swiftjava_SwiftModule_MyStruct_subscript$set.call(index, newValue, this.$memorySegment());
""",
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the chunks which we do want to assert on, looking good, thanks!

return MyStruct.$typeMetadataAddressDowncall();
}
"""
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same request about only the subscript text chunks as in the ffm one

@ktoso ktoso changed the title Subscripts support jextract (ffm, jni): Subscripts support Nov 25, 2025
@ktoso
Copy link
Collaborator

ktoso commented Nov 25, 2025

Very nice, just some nitpicks about the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JExtract] Support subscript APIs

2 participants